package com.chrome.sms;

import android.app.Activity;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

public class chromesms extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        registerIntent();
    }
    
    public void registerIntent(){
    	// Use the Intent API to get a registration ID
    	// Registration ID is compartmentalized per app/device
    	Intent regIntent = new Intent("com.google.android.c2dm.intent.REGISTER");
    	// Identify your app
    	regIntent.putExtra("app",PendingIntent.getBroadcast(this /*your activity*/,0, new Intent(), 0));
    	// Identify role account server will use to send
    	regIntent.putExtra("sender", "deniszgonjanin@gmail.com");
    	// Start the registration process
    	startService(regIntent);
    }
    
 // Registration ID received via an Intent
    public void onReceive(Context context, Intent intent) {
      String action = intent.getAction();
      if ( "com.google.android.c2dm.intent.REGISTRATION".equals(action)) {
        handleRegistration(context, intent);
      }
    }

    public void handleRegistration(Context context, Intent intent) {
      String id = intent.getStringExtra("registration_id");
      if ((intent.getStringExtra("error") != null)) {
        // Registration failed.  Try again later, with backoff.
      } else if (id != null) {
        // Send the registration ID to the app’s server.
        // Be sure to do this in a separate thread.
      }
    }
}